package com.design_pattern._03_behavioral._04_templateMethod;

public abstract class Person {
    public void eat(){
        System.out.println(getClass().getSimpleName()+"开始吃"+food());
    }
    abstract String food();

    public static void main(String[] args) {
        Person american = new American();
        Person chiness = new Chinese();
        american.eat(); // eat方法就是模板，具体的food，由人种决定
        chiness.eat();
    }
}

class American extends Person{
    @Override
    String food() {
        return "面包";
    }
}


class Chinese extends Person{
    @Override
    String food() {
        return "面条";
    }
}